﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using ShootThemUp.Sources.GameElements;

namespace ShootThemUp.Sources.GameElements
{
    /// <summary>
    /// It is a sprite which is movable.
    /// </summary>
    public class MovableSprite : Sprite
    {

        #region Fields

        private Vector2 speed;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the speed of the sprite.
        /// </summary>
        /// <value>
        /// The speed of the sprite.
        /// </value>
        public Vector2 Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MovableSprite"/> class.
        /// </summary>
        public MovableSprite() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="MovableSprite"/> class.
        /// </summary>
        /// <param name="position">The position of the sprite.</param>
        /// <param name="speed">The speed of the sprite.</param>
        /// <param name="sourceRectangle">The source rectangle.</param>
        public MovableSprite(Vector2 position, Vector2 speed,Rectangle? sourceRectangle)
            : base(position, sourceRectangle)
        {
            this.Speed = speed;
        }

        public MovableSprite(Vector2 position, Vector2 speed, Rectangle? sourceRectangle, Rectangle? hitbox)
            : base(position, sourceRectangle, hitbox)
        {
            this.Speed = speed;
        }
        #endregion

        #region Update

        /// <summary>
        /// Updates the sprite position in function of the specified game time.
        /// </summary>
        /// <param name="gameTime">A snapshot of the current time.</param>
        public virtual void Update(GameTime gameTime)
        {
            this.Position += this.Speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
        }

        #endregion
    }
}
